#include "SeqStack.h"

template<typename T>
SeqStack<T>::SeqStack(void)
{
	top=-1;
}

template<typename T>
SeqStack<T>::~SeqStack(void)
{
}

template<typename T>
void SeqStack<T>::Push(T value)
{
	if (top >= StackSize-1)
	{
		cout<<"overflow"<<endl;
	}
	top++;
	data[top] = value;
}

template<typename T>
T SeqStack<T>::Pop()
{
	if(IsEmpty())
	{
		cout<<"underflow"<<endl;
		return ;
	}
	top--;
	return data[top+1];
}

template<typename T>
T SeqStack<T>::GetTop()
{
	if(IsEmpty())
	{
		cout<<"underflow"<<endl;
		return ;
	}
	return data[top];
}

template<typename T>
bool SeqStack<T>::IsEmpty()
{
	return top==-1? true: false;
}

template<typename T>
void SeqStack<T>::PrintStack()
{
	if (IsEmpty())
	{
		cout<<"underflow"<<endl;
		return ;
	}
	for (int i=0; i<=top; i++)
	{
		cout<<data[i]<<"   ";
	}
}